﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using Gios.Word;

namespace PostCFAST
{

    class word
    {
        [STAThread]
        //static 
        public void work1()
        { 
            Gios.Word.WordDocument rd = new WordDocument(WordDocumentFormat.Letter_8_5x11);

            Font bold = new Font("Helvetica", 12, FontStyle.Bold);
            Font regular = new Font("Helvetica", 12, FontStyle.Regular);
            rd.SetFont(bold);
            rd.SetTextAlign(WordTextAlign.Left);
            WordTable rt = rd.NewTable(regular, Color.Black, 7, 4, 0);
            rt.SetColumnsWidth(new int[] { 50, 9, 40, 1 });
            //foreach (WordCell rc in rt.Cells) rc.SetBorders(Color.Black,1,true,true,true,true);

            rt.SetContentAlignment(ContentAlignment.TopLeft);
            rt.Rows[0].SetRowHeight(300);
            rt.Rows[1].SetRowHeight(1400);
            rt.Rows[0][0].RowSpan = 3;
            rt.Rows[0][0].SetContentAlignment(ContentAlignment.MiddleCenter);
            rt.Rows[0][0].PutImage(@"cp.jpg", 70);  //@"..\..\cp.jpg"
            rt.Rows[1][2].SetCellPadding(100);
            rt.Rows[1][2].SetContentAlignment(ContentAlignment.MiddleLeft);
            rt.Rows[1][2].SetFont(new Font("Helvetica", 9, FontStyle.Bold));
            rt.Rows[1][2].WriteLine("GIOS PAOLO");
            rt.Rows[1][2].WriteLine("ELM STREET, 59");
            rt.Rows[1][2].Write("SPRINGFIELD");
            rt.Rows[1][2].SetBorders(Color.Black, 1, true, true, true, true);
            ;
            rt.Rows[4][0].SetFont(bold);
            rt.Rows[4][0].ColSpan = 4;
            rt.Rows[4][0].WriteLine();
            rt.Rows[4][0].WriteLine("Gios Technologies - Power With Semplicity.\n\n");

            rt.Rows[5][0].WriteLine(DateTime.Today.ToLongDateString() + "\n\n\n\n");
            rt.Rows[5][1].ColSpan = 3;
            rt.Rows[5][1].SetContentAlignment(ContentAlignment.TopRight);
            rt.Rows[5][1].WriteLine("Receipt Number 01302");

            WordCell body = rt.Rows[6][0];
            body.ColSpan = 4;
            body.SetFont(bold);
            body.WriteLine("WORD .NET:");
            body.WriteLine();
            body.SetFont(regular);
            body.WriteLine("A complete library in c# for generating Word Documents using the Rich Text Format Specification!");
            body.WriteLine();
            body.WriteLine();
            body.SetFont(bold);
            body.Write("blah blah blah... ");
            body.SetFont(regular);
            body.WriteLine("blah blah blah\n");

            rt.SaveToDocument(10000, 0);
            rd.SetPageNumbering(12);

            rd.HeaderStart();
            rd.SetTextAlign(WordTextAlign.Center);
            rd.SetFont(new Font("Verdana", 10, FontStyle.Bold));
            rd.Write("Paolo Gios, ICT Consultant - http://www.paologios.com");
            rd.WriteLine();
            rd.HeaderEnd();

            rd.FooterStart();
            rd.SetTextAlign(WordTextAlign.Center);
            rd.SetFont(new Font("Verdana", 10, FontStyle.Bold));
            rd.Write("Copyright © 2005 by Paolo Gios - All rigths reserved");
            rd.FooterEnd();


            rd.SaveToFile("..\\..\\Example1.doc");
            System.Diagnostics.Process.Start("..\\..\\Example1.doc");

        }

        [STAThread]
        public void work2()
        {

            // Create a new Word Document
            WordDocument rd = new WordDocument(WordDocumentFormat.Letter_8_5x11_Horizontal);

            // Sets a text effect using a custom control word. See RTF spefications for further implementations.
            rd.WriteControlWord("animtext3");

            // I think that there's no need of explanaition...
            rd.SetFontBackgroundColor(Color.Yellow);
            rd.SetForegroundColor(Color.Red);
            rd.SetFont(new Font("Arial", 30));
            rd.SetTextAlign(WordTextAlign.Center);

            rd.WriteLine("GIOS WORD.NET Features Test");

            // Reset the text effect using a custom control word.
            rd.WriteControlWord("animtext0");

            // Resets the colors
            rd.SetFontBackgroundColor();
            rd.SetForegroundColor(Color.Black);

            rd.WriteLine();

            WordTable rt1 = rd.NewTable(new Font("Arial", 12), Color.Red, 2, 2, 2);
            rt1.Rows[0][0].Write("hello");
            rt1.SetBorders(Color.Red, 2, true, true, true, true);
            rt1.SaveToDocument(3000, 4000);
            rd.WriteLine();

            WordTable rt2 = rd.NewTable(new Font("Arial", 12), Color.Blue, 2, 4, 2);
            rt2.Rows[0][0].Write("hello");
            rt2.SaveToDocument(3000, 0);
            rd.WriteLine();

            // We can also set the starting page of the document.
            rd.SetPageNumbering(999);

            // In a object oriented document description, we can set the header
            // and the footer just we want to do it!
            rd.HeaderStart();
            rd.SetTextAlign(WordTextAlign.Center);
            rd.SetFont(new Font("Verdana", 10, FontStyle.Bold));
            rd.Write("Paolo Gios, ICT Consultant - http://www.paologios.com");
            rd.WriteLine();
            rd.HeaderEnd();

            rd.FooterStart();
            rd.SetTextAlign(WordTextAlign.Center);
            rd.SetFont(new Font("Verdana", 10, FontStyle.Bold));
            rd.Write("Copyright © 2005 by Paolo Gios - All rigths reserved");
            rd.FooterEnd();

            rd.NewPage();

            rd.SetTextAlign(WordTextAlign.Left);
            rd.WriteLine();
            rd.WriteLine("And this is a list using the line indent:");
            rd.WriteLine();
            // this sets the distance from the margin
            rd.SetParagraph(500);
            rd.WriteLine("- One");
            rd.WriteLine("- Two");
            rd.WriteLine("- Three");
            // resets the paragraph
            rd.SetParagraph();
            rd.WriteLine();
            rd.WriteLine("That's all... Enjoy!");

            rd.SaveToFile("..\\..\\Example2.doc");
            System.Diagnostics.Process.Start("..\\..\\Example2.doc");

        }


    }
}
